var sel = fl.getDocumentDOM().selection;

sel.sort(sortTopLeft);

function sortTopLeft(a, b) {
	if (a.y < b.y) return -1;
	if (a.y == b.y) {
		if (a.x < b.x) return -1;
		else if (a.x > b.x) return 1;
		else return 0;
	}
	if (a.y > b.y) return 1;
}

var iLen = sel.length;
for (var i = 0; i < iLen; i++) {
	sel[i].name = "s" + (i + 1);
}

